<template>
  <el-card class="box-card" shadow="never">
    <div slot="header">
      <span>📢推广</span>
    </div>
    <div>
      <p v-for="(item,index) in list" :key="index" class="block">
        <a :href="item.link" target="_blank">{{ item.title }}</a>
      </p>
    </div>
  </el-card>
</template>

<script>
//第一：导入接口
import { getPromotionAll } from "@/api/doubaoApi";

export default {
  name: "PromotionCard",
  data() {
    return {
      list: []
    };
  },
  //第二：页面创建时调用的方法
  created() {
    this.fetchPromotionAll();
  },
  methods: {
    fetchPromotionAll() {
      //第三：方法中调用接口，接受传回来的json对象
      getPromotionAll().then((response) => {
        const { data } = response
        this.list = data
      })
    },
  },
};
</script>